package image

import (
	"fmt"
	"strings"
)

const (
	// MicroDNF is the base image with debugging tools.
	MicroDNF = "opencloudos/opencloudos9-microdnf:latest"
	// Minimal is the slim production base image.
	Minimal = "opencloudos/opencloudos9-minimal:latest"
)

// SelectBaseImage chooses an appropriate base image based on the given mode.
// Modes associated with debugging ("debug", "dev", "development") return the
// MicroDNF image which contains debugging tools. Lightweight or production
// modes ("production", "prod", "lightweight", "") return the Minimal image.
// An error is returned for any unrecognized mode.
func SelectBaseImage(mode string) (string, error) {
	switch mode {
	case "debug", "dev", "development":
		return MicroDNF, nil
	case "production", "prod", "lightweight", "":
		return Minimal, nil
	default:
		supported := []string{"debug", "dev", "development", "production", "prod", "lightweight"}
		return "", fmt.Errorf("unsupported mode %q: must be one of %s", mode, strings.Join(supported, ", "))
	}
}
